<template>
  <div class="top-left-cmp">
    <div class="dc-left">
      <dv-border-box-5 style="padding-top: 60px">
        <div class="main-value"><span>{{cData.thisMonth}}</span>条</div>
        <div class="compare-value" style="margin-top: 10px"><span>同比</span>{{cData.lastMonthRatio}}%</div>
        <div class="compare-value"><span>环比</span>{{cData.thisMonthRatio}}%</div>
      </dv-border-box-5>
      <div class="dc-text">
        当日故障处理条数
        <dv-decoration-3 style="width:200px;height:20px;" />
      </div>
    </div>
    <div class="dc-right">
      <div class="dc-text">
        当月故障条数
        <dv-decoration-3 style="width:200px;height:20px;" />
      </div>
      <dv-border-box-5 :reverse="true" style="padding-top: 60px">
        <div class="main-value"><span>{{cData.thisDay}}</span>条</div>
        <div class="compare-value" style="margin-top: 10px"><span>同比</span>{{cData.lastDayRatio}}%</div>
        <div class="compare-value"><span>环比</span>{{cData.thisDayRatio}}%</div>
      </dv-border-box-5>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    chartData: {
      type: Object,
      required: true
    }
  },
  name: 'TopLeftCmp',
  data() {
    return {
      centerData: {
        type: Object,
        required: true
      },
      cData:{
        thisMonth:0,
        thisMonthRatio:0,
        lastMonthRatio:0,
        thisDay:0,
        thisDayRatio:0,
        lastDatRatio:0
      }
    };
  },
  watch: {
    chartData: {
      handler(newData) {
        console.log('falut:::',newData)
        if(newData != null && newData != undefined){
          const faultMonthRatio = newData.fault.faultMonthRatio
          const faultDayRatio = newData.fault.faultDayRatio
          if(faultMonthRatio != undefined && faultMonthRatio != null )
          {
            this.cData.thisMonth = faultMonthRatio.thisMonthFault
            this.cData.thisMonthRatio = faultMonthRatio.monthRatio
            this.cData.lastMonthRatio = faultMonthRatio.yearRatio
          }
          if(faultDayRatio != undefined && faultDayRatio != null )
          {
            this.cData.thisDay = faultDayRatio.thisDayFault
            this.cData.thisDayRatio = faultDayRatio.dayRatio
            this.cData.lastDayRatio = faultDayRatio.monthRatio
          }
        }
      },
      immediate: true,
      deep: true
    }
  }
}
</script>

<style lang="scss">
.top-left-cmp {
  display: flex;

  .dc-left, .dc-right {
    width: 50%;
  }

  .dv-border-box-5 {
    height: 60%;
  }

  .dc-text {
    display: flex;
    flex-direction: column;
    height: 40%;
    font-size: 20px;
    padding: 20px;
    box-sizing: border-box;
  }

  .dc-left .dc-text {
    align-items: flex-end;
    justify-content: center;
  }

  .dc-right .dc-text {
    justify-content: flex-start;
    padding-top: 20px;
  }

  .dc-left .dv-border-box-5 {
    padding: 30px;
    box-sizing: border-box;
  }

  .dc-right .dv-border-box-5 {
    padding: 40px;
    padding-left: 75px;
    box-sizing: border-box;
  }

  .main-value {
    font-weight: bold;
    font-size: 30px;

    span {
      font-size: 50px;
      color: #00c0ff;
      margin-right: 15px;
    }
  }

  .compare-value {
    height: 35px;
    line-height: 35px;
    font-size: 18px;

    span {
      margin-right: 30px;
    }
  }
}
</style>
